//用户模块数据
import {RECEIVE_USER, SAVE_TOKEN} from "../mutation-types";

export default {
    state: {
        userInfo: {},
        token: ''
    },
    mutations: {
        [RECEIVE_USER](state, user) {
            state.userInfo = user
        },
        [SAVE_TOKEN](state, token) {
            state.token = token
        },
    },
    actions: {
        //将用户保存到vuex
        getUser({commit}, userInfo) {
            commit(RECEIVE_USER, userInfo)
        },
        //保存token
        saveToken({commit}, token) {
            commit(SAVE_TOKEN, token)
        },
    },
    getters: {}
}